﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UnityScriptEngine;

namespace MBB_Payroll_Terminal
{
    public partial class frmPassword : Form
    {
        public frmPassword()
        {
            InitializeComponent();
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            
            btnOk.Click += new EventHandler(btnOk_Click);
            txtPwd.KeyPress += new KeyPressEventHandler(txtPwd_KeyPress);
        }

        void txtPwd_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                btnOk_Click(sender,null);
            }
        }
        void btnOk_Click(object sender, EventArgs e)
        {
            if (UnityProcessor.Settings.DBPU_UID == null)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else if (txtPwd.Text.Equals(UnityProcessor.Settings.DBPU_UID))
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Invalid Password!");
                this.Close();
            }
        }
        
    }
}
